package com.bwie.service.impl;

import com.bwie.common.constants.Constants;
import com.bwie.common.domain.Message;
import com.bwie.common.exceptions.LiteratureInfoExceptions;
import com.bwie.mapper.UserLiteratureMapper;
import com.bwie.service.UserLiteratureService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @className: UserLiteratureServiceImpl
 * @Description: TODO
 * @version: v1.８.0
 * @author: 李明
 * @date: 2025/11/10 14:05
 */
@Service
public class UserLiteratureServiceImpl implements UserLiteratureService {

    @Autowired
    private UserLiteratureMapper userLiteratureMapper;


    /**
     * 添加我的资源列表
     * @param message
     */
    @Override
    public void addMyLiterature(Message message) {
        Integer userId = message.getUserId();
        Integer literatureId = message.getLiteratureId();
        if (null == userId){
            throw new LiteratureInfoExceptions(Constants.LITERATURE_DATA_BLANK_CODE,
                    Constants.LITERATURE_DATA_BLANK_MSG);
        }
        if (null == literatureId){
            throw new LiteratureInfoExceptions(Constants.LITERATURE_DATA_BLANK_CODE,
                    Constants.LITERATURE_DATA_BLANK_MSG);
        }

        //添加数据信息
        userLiteratureMapper.addMyLiterature(message);
    }

}
